class Scene extends eui.Component {
    public backLayer: eui.Group;
    public mainLayer: eui.Group;
    public frontLayer: eui.Group;

    public constructor() {
        super();
    }

    private loadResources(resList: Array<Object>) {
        try {
            if (resList) {
                for (const res of resList) {
                    egret.log('res', res);
                }
            }
            this.addEventListener(egret.Event.ADDED_TO_STAGE, this.initLayers, this);
        }
        catch (e) {
            console.error(e);
        }
    }

    public init(skinName: string, resList: Array<Object> = null) {
        this.skinName = skinName;
        this.loadResources(resList);
    }

    private initLayers() {
        this.backLayer = new eui.Group();
        this.mainLayer = new eui.Group();
        this.frontLayer = new eui.Group();
        this.addChild(this.backLayer);
        this.addChild(this.mainLayer);
        this.addChild(this.frontLayer);
        EventDispatcher.getInstance.resourceLoadReady(this);
    }

    public addToBack(elm: egret.DisplayObject) {
        this.backLayer.addChild(elm);
    }

    public addToMain(elm: egret.DisplayObject) {
        this.mainLayer.addChild(elm);
    }

    public cleanMain() {
        this.mainLayer.removeChildren();
    }

    public addToFront(elm: egret.DisplayObject) {
        this.frontLayer.addChild(elm);
    }
}
